package com.bieyang.anjia.ui.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;

import com.bieyang.anjia.R;
import com.bieyang.anjia.net.NetManager;
import com.bieyang.anjia.utils.ShowProgress;
import com.bieyang.anjia.utils.SubUtils;

/**
 * 
 * @author Administrator
 * 滑动不删除界面
 */
public abstract class BaseNoFlyActivity extends BaseActivity {
	public Context con;
	public SubUtils subUtils;
	public ShowProgress progressDialog;
	public String uuid, id, name;
	public boolean isSetted = false;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		con = this;
		subUtils = new SubUtils();
		Intent intent = getIntent();
		uuid = intent.getStringExtra("uuid");
		id = intent.getStringExtra("id");
		name = intent.getStringExtra("name");
		Log.d("uuid", uuid + "");
		Log.d("id", id + "");
		Log.d("name", name + "");
		setContent();
		initView();
		initData();
		setOnClickListener();
		setListener();
	}

	void setOnClickListener() {
		Button imgBack = (Button) findViewById(R.id.backToHomePage);
		imgBack.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				if ("ONLINE".equals(NetManager.subOnLineMap.get(uuid))) {
					saveStatus();
				} else {
					finish();
				}
			}
		});
	}

	@Override
	protected void onDestroy() {
		// TODO Auto-generated method stub
		super.onDestroy();
		if (null != progressDialog && progressDialog.isShowing()) {
			progressDialog.dismiss();
		}
	}

	/**
	 * setContentView 及初始化
	 */
	abstract void setContent();

	abstract void initView();

	abstract void initData();

	abstract void setListener();

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		// TODO Auto-generated method stub
		switch (keyCode) {
		case KeyEvent.KEYCODE_BACK:
			if ("ONLINE".equals(NetManager.subOnLineMap.get(uuid))) {
				saveStatus();
			} else {
				finish();
			}
			break;
		default:
			break;
		}
		return super.onKeyDown(keyCode, event);
	}

	protected void saveStatus() {
	}
}
